
Free Online Sort Text Lines Alphabetically
Sort any list alphabetically, in reverse, by number, by length or randomly, with options for case, accents and duplicates.
A sorted list is easier to scan, easier to check and easier to compare. Names, tags, file lists, glossary terms, to-do items: all are clearer in order. This tool sorts your lines in one click and gives you six kinds of order, plus a random shuffle for when you want the opposite of order.
The kinds of sorting
| Mode | What it does | Good for |
|---|---|---|
| A to Z | Alphabetical order | Names, terms |
| Z to A | Reverse alphabetical order | Finding the last items first |
| Natural | Reads numbers inside lines as numbers | File names such as item2, item10 |
| Number found | Sorts by the first number in each line | Prices, scores, ranks |
| Length | Short lines first | Spotting very long entries |
| Reverse order | Flips the list upside down | Newest first logs |
| Shuffle | Random order | Draws, quiz order |
Why “natural” order exists
A plain alphabetical sort compares character by character. The text “item10” begins with “item1”, and “1” comes before “2”, so “item10” lands before “item2”. That is correct for letters but wrong for numbers. Natural sort treats a run of digits as a single number, so item2 comes before item10, which is what people expect. Use it for file names, chapters, room numbers and version labels.
Accents, case and other languages
The tool uses your browser’s built-in collation rules rather than raw character codes. This matters. In raw code order, every capital letter comes before every lowercase letter, so “Zebra” would sort before “apple”. The built-in rules place “apple” before “Zebra” and put accented letters such as “É” next to “E”. By default, differences in case and accents do not change the order. Tick “Treat A and a as different” if you want upper-case words to come first when two lines are otherwise equal. Languages sort differently from each other, and your browser follows your own language settings, so results can vary slightly by device.
How to use it
- Paste your list, one item per line.
- Choose how to sort.
- Choose the extra options: trim spaces, remove empty lines, remove duplicates and number the result.
- Copy the result, download it or send it back to the input to sort again by a different rule.
A worked example
Press the example button. The list is item10, banana, Item2, Éclair, apple, item1, cherry. With A to Z, the result is apple, banana, cherry, Éclair, item1, item10, Item2. The accented word sits among the “e” words, but the item lines are compared one character at a time, so item10 comes before Item2. Switch to natural order, and the three item lines appear as item1, Item2, item10, with 2 before 10. Switch to length and the shortest lines come first. Choose shuffle and you get a different order each time, using the browser’s secure random number generator rather than a biased trick.
Sorting by the number in a line
In “Number found” mode, the tool looks for the first number in each line, including negatives and decimals, and sorts by it. A list such as “x 10”, “x 2”, “y” and “x -5” becomes x -5, x 2, x 10, and then y, because lines with no number go to the end. Thousands separators such as 1,200 are read as 1200. If your numbers use a decimal comma, replace commas first.
Real lists, real orders
Think about a glossary for a course. Terms start with capitals or lower case depending on who typed them, and a few start with a quote mark or a digit. Sorting with case ignored puts them in the order a reader expects. Think about a playlist file: sorting by length helps you find the one entry that is unusually long and probably wrong. Think about a list of invoices named inv-9, inv-10 and inv-100: natural order gives you the sequence you would count in. And think about a class register: a Z to A pass followed by a reverse puts the last names at the top when you need to start from the end of the alphabet.
Common mistakes
- Sorting a list with leading spaces. Keep “Trim spaces first” ticked.
- Expecting numbers to sort numerically in plain alphabetical mode.
- Forgetting that blank lines sort first. Remove them with the option.
- Sorting a table by pasting columns. Sort only one column at a time, or use a spreadsheet for multi-column data.
- Using shuffle for a prize draw that needs auditable results. Use a dedicated random picker for that.
About the shuffle
A fair shuffle gives every possible order the same chance. The tool uses the Fisher-Yates method with numbers from the browser’s cryptographic random generator, and it avoids the small bias that comes from using a simple remainder. Press “Shuffle again” for a new order. For a formal draw, you can also try the random name picker when it is live.
Where your list goes, and how big it can be
Sorting happens inside your own browser, and nothing you paste is uploaded or kept anywhere else. The tool handles up to roughly four million characters. Very long lists may take a moment to sort, but the page will stay responsive.
To remove repeats first, use the remove duplicate lines tool. To explore ordering in spreadsheets, take the Excel course, and to keep your files in order, read how to organise files and folders.
Key takeaways
- Natural sort puts item2 before item10.
- Browser collation handles accents and case sensibly.
- Trim spaces and remove empty lines for a clean result.
- Shuffle uses secure random numbers.
Questions
What is natural sort order?
Natural sort treats runs of digits as numbers, so item2 comes before item10. A plain alphabetical sort compares one character at a time and would put item10 first because 1 comes before 2. Natural order matches how people read file names, chapters, versions and room numbers.
Does the sorter handle accented letters?
Yes. It uses your browser's language-aware comparison, so an accented letter such as É sorts next to E instead of after Z. Upper and lower case are treated as equal by default. Order for some languages can differ slightly between devices, because it follows your browser's language settings.
How do I sort numbers correctly?
Use Natural for numbers inside names, or Number found to sort by the first number in each line, which also handles negatives and decimals. In plain A to Z mode, a list of numbers sorts as text, so 10 would come before 2. Lines with no number go at the end.
Is the shuffle really random?
It uses the Fisher-Yates algorithm with numbers from the browser's cryptographic random generator and removes the small bias that a simple remainder would add. That is suitable for casual use. For prize draws that need audits or fairness proofs, use a process that others can verify.
Can it remove duplicates while sorting?
Yes. Tick Remove duplicates and the list is first reduced to unique lines, ignoring case unless you ask it to be strict, and then sorted. You can also add numbers to the result, trim spaces and drop blank lines in the same run, then copy or download the result.
